package first.endtoend

import first.endtoend.Category
import first.endtoend.RationCard
import first.endtoend.Tag
import first.endtoend.Trace
import first.endtoend.messages.MessageCode

class CategoryTraceService
{

    def tagService

    def serviceMethod()
    {

    }

    def toJson(Category aCategory)
    {
        def listResult = new ArrayList<Trace>()
        RationCard rationCard
        Tag tag
        // int count= 0
        if (aCategory)
        {

            if (aCategory.families)
            {
                listResult = new ArrayList<Tag>()
                aCategory.families.each {           //TODO do control for tag
                    listResult.add(tagService.toJson(it))

                }
                [
                        id         : aCategory.id,
                        name       : aCategory.name,
                        code       : MessageCode.SUCCESS.value(),
                        traces     : listResult.get(0),
                        tracesCount: listResult.size()

                ]

            }
        }
    }
}
